package com.shanghaiyimu.yimiyangche.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.shanghaiyimu.yimiyangche.R;
import com.shanghaiyimu.yimiyangche.adapter.HotTieAdapter;
import com.shanghaiyimu.yimiyangche.bean.HotTiewItemBean;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class HotTieFragment extends Fragment {


    public HotTieFragment() {
        // Required empty public constructor
    }
    private PullToRefreshListView pullToRefreshListView;

    private HotTieAdapter adapter;
    private List<HotTiewItemBean> data = new ArrayList<>();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_hot_tie, container, false);
        initView(view);
        initData();
        return view;
    }

    private void initData() {

        for (int i = 0; i < 16; i++) {
            HotTiewItemBean bean = new HotTiewItemBean();
            bean.setWen("轮胎多久换一次"+i);
            bean.setDa("6."+i);
            data.add(bean);
        }
        adapter.notifyDataSetChanged();
    }

    private void initView(View view) {
        pullToRefreshListView = (PullToRefreshListView) view.findViewById(R.id.fragment_hot_toe_ptrlistview);
        adapter = new HotTieAdapter(getContext(),data);
        pullToRefreshListView.setAdapter(adapter);
    }

}
